@extends('home.wechat.layouts.app')
@section('content')
    <div class="page-search" data-log="搜索页">
        <div class="header">
            <div class="left">
                <a href="/wechat" title="fangshop小卖部" data-log="HEAD-首页" class="home">
                    <span class="icon-home icon"></span>
                </a>
            </div>
            <div class="tit">
                <div class="searchword"><input autofocus="autofocus"></div>
            </div>
            <div class="searchlabel">
                <a>
                    <span class="icon icon-search"></span>
                </a>
            </div>
        </div>
        <div>
            <ul class="list-default">
                @foreach($products as $product)
                <li @if($product->is_top=='1') class="top" @endif onclick="location.href='/wechat/product/{{$product->id}}'"><span>{{$product->name}}</span></li>
                @endforeach
            </ul>
        </div>
    </div>
    @endsection
@section('js')
    <script>
        $(function(){
            //点击搜索按钮，向/wechat/product/index方法传递参数searchword
            $('.icon-search').click(function(){
                var searchword=$.trim($('.searchword').children('input').val());
                location.href="/wechat/product/index?searchword="+searchword;
            })
        })
    </script>
@endsection